<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page import="com.tjtt.tdm.base.PubMethod" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String formname = request.getParameter("formname");
String formid = request.getParameter("formid");
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">   
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">  
  <head>
  <base target="_self"/>
  
  <title>添加已存在表</title>
  	<%@ include file="../jslib/jquerylib.jsp" %> 
	<link rel="stylesheet" type="text/css" href="<%=path %>/web/style/layout.css" />
    <script type="text/javascript" src="<%=path %>/jslib/jquery.validate.min.js"></script>
    <script type='text/javascript' src="<%=request.getContextPath() %>/jslib/My97DatePicker/WdatePicker.js"  defer="defer"></script>
    <script type='text/javascript' src="<%=request.getContextPath() %>/jslib/jquery.form.js"></script>
    <script type="text/javascript" src="<%=request.getContextPath() %>/jslib/additional-methods.js"></script>
    <link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/jslib/jquery-easyui-1.4.1/themes/default/easyui.css" />
	<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/jslib/jquery-easyui-1.4.1/themes/icon.css" />
	<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/jslib/jquery-easyui-1.4.1/demo.css" />
	<script type="text/javascript" src="<%=request.getContextPath() %>/jslib/jquery-easyui-1.4.1/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="<%=request.getContextPath() %>/jslib/lhgdialog/lhgcore.lhgdialog.min.js?skin=mac"></script>

    <c:if test="${requestScope.message!=null}">
		<script type="text/javascript">
 	 		     alert('<c:out value="${requestScope.message}"></c:out>');
 	 		     window.close();
 		</script>
	</c:if>

<script>
var api = frameElement.api, W = api.opener;
$().ready(function() {
    	// 准备好Options对象
    	var options = {
    	    url:'<%=request.getContextPath() %>/saveAutoFormsAndOldTable.action',
    		beforeSubmit: checkForm,
    	    dataType:'json',
    	    success: function(data) {
    	      if(data.result=='success'){
				alert("添加成功");
				api.close();
				W.refreshIt();
    	      }else if(data.result=='errorExist'){
    	      	alert("此表已添加过，请修改表英文名称！");
    	      	$("#formEnName").focus();
    	      }else if(data.result=='errorNoExist'){
    	      	alert("数据库不存在此表，请修改表英文名称！");
    	      	$("#formEnName").focus();
    	      }else{
    	      	alert("系统繁忙，请您稍后再试！");
    	      	api.close();
				W.refreshIt();
    	      }
    	}};
    	
		$('#saveBtn').click(function(){
			$('#pageFrom').ajaxSubmit(options);
			return false;
		});
		
		$('#closeBtn').click(function(){
			api.close();
		});
	});
	 function checkForm(){
			var flag = true;
			var formCnName = $("#formCnName").val();
			if(formCnName==''){
	      		alert("表单中文名称不能为空!");
				$("#formCnName").focus();
				return false;
	        }else if(!checkExp(formCnName)){
				alert("表单中文名称不能含有除_以外的特殊符号!");
				$("#formCnName").focus();
				return false;
		   } 
	}	
	 //验证特殊字符
	function checkExp(inputData){ 
		var regEx = new RegExp(/^(([^\^\.<>%&',:;=?$"'#@!~\]\[{}【】￥（）！·‘’”“。，、？：；—|\/\\/`\|])*)$/);
		var result = inputData.match(regEx);
		if (result == null) {
		return false;
		}
		return true;
	} 		
</script>
 <style type="text/css">
	body{
		background:#ffffff; background-image:url(images/);
	}
</style>
</head>
<body>
  	<form action="" id="pageFrom" name="" method="post">
  		<table width="100%" border="0" align="center" cellpadding="5" cellspacing="5" class="formTableNew">
  		<input type="hidden" id="formId" name="formId" value=""  />
  		<tr>
		    <td align="right">表单中文名称：</td>
		    <td align="left">
				<input type="text" id="formCnName" name="formCnName" />
				<img src="<%=request.getContextPath() %>/images/xh.png"></img>
		    </td>
		  </tr>
		  <tr>
		    <td align="right">表单英文名称：</td>
		    <td align="left">
				<input type="text" id="formEnName" name="formEnName"  />
				<img src="<%=request.getContextPath() %>/images/xh.png"></img>
		    </td>
		  </tr>
		  <tr>
		    <td align="center" colspan="2" >
		    	<input type="button" id="saveBtn" value="提 交" class="form_bt_orange" />
		      	<input type="button" id="closeBtn" value="取 消" class="form_bt_grey" />
		    </td>
		  </tr>
		</table>
	</form>
  </body>
</html>
